const baseUrl = "http://jacklv.cn:3001"
export default function request(url, option = {}) {
	let head={}
	if(uni.getStorageSync('token')){
		
		head={'Authorization':uni.getStorageSync('token')}
	}
	
	const finallyUrl=url.indexOf('http')!=-1?url:baseUrl+url
	return new Promise((resolve, reject) => {
		uni.showLoading()
		uni.request({
			url: finallyUrl,
			method: option.method ? option.method : 'GET',
			data: option.data,
			header:head,
			success(res) {
				switch (res.statusCode) {
					case 200:
						return resolve(res.data)
					default:
						reject(res.data.meta)
				}
			},
			fail() {

			},
			complete() {
				uni.hideLoading()
			}
		})
	})
}
